---
title: Collapsible
description: An interactive component which expands/collapses a panel.
component: true
kobalte:
    link: https://kobalte.dev/docs/core/components/collapsible
    api: https://kobalte.dev/docs/core/components/collapsible#api-reference
---

<ComponentPreview name="collapsible-demo" />

## Installation

<Tabs defaultValue="cli">

<TabsList>
    <TabsTrigger value="cli">CLI</TabsTrigger>
    <TabsTrigger value="manual">Manual</TabsTrigger>
    <TabsIndicator class="bg-primary" />
</TabsList>

<TabsContent value="cli">

<Steps>

<Step>Run the following command:</Step>

```bash
npx shadcn-solid@latest add collapsible
```

<Step>Update `tailwind.config.cjs`</Step>

Add the following animations to your `tailwind.config.cjs` file:

```js title="tailwind.config.cjs" {5-18}
/** @type {import('tailwindcss').Config} */
module.exports = {
    theme: {
        extend: {
            keyframes: {
                "collapsible-down": {
                    from: { height: 0 },
                    to: { height: "var(--kb-collapsible-content-height)" },
                },
                "collapsible-up": {
                    from: { height: "var(--kb-collapsible-content-height)" },
                    to: { height: 0 },
                },
            },
            animation: {
                "collapsible-down": "collapsible-down 0.2s ease-out",
                "collapsible-up": "collapsible-up 0.2s ease-out",
            },
        },
    },
}
```

</Steps>

</TabsContent>

<TabsContent value="manual">

<Steps>

<Step>Install the following dependencies:</Step>

```bash
npm install @kobalte/core
```

<Step>Copy and paste the following code into your project.</Step>

<ComponentSource name="collapsible" />

<Step>Update the import paths to match your project setup.</Step>

<Step>Update `tailwind.config.cjs`</Step>

Add the following animations to your `tailwind.config.cjs` file:

```js title="tailwind.config.cjs" {5-18}
/** @type {import('tailwindcss').Config} */
module.exports = {
    theme: {
        extend: {
            keyframes: {
                "collapsible-down": {
                    from: { height: 0 },
                    to: { height: "var(--kb-collapsible-content-height)" },
                },
                "collapsible-up": {
                    from: { height: "var(--kb-collapsible-content-height)" },
                    to: { height: 0 },
                },
            },
            animation: {
                "collapsible-down": "collapsible-down 0.2s ease-out",
                "collapsible-up": "collapsible-up 0.2s ease-out",
            },
        },
    },
}
```

</Steps>

</TabsContent>

</Tabs>

## Usage

```tsx
import {
    Button,
    Collapsible,
    CollapsibleContent,
    CollapsibleTrigger,
} from "@/components/ui/collapsible"
```

```tsx
<Collapsible>
    <CollapsibleTrigger>Can I use this in my project?</CollapsibleTrigger>
    <CollapsibleContent>
        Yes. Free to use for personal and commercial projects. No attribution
        required.
    </CollapsibleContent>
</Collapsible>
```
